package cn.iocoder.yudao.module.system.controller.admin.ivrs;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.a_pictures.vo.PicturesPageReqVO;
import cn.iocoder.yudao.module.system.service.ivrs.IvrsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * TODO
 *
 * @author sun
 * @date 9:51 2024/9/23
 **/
@Tag(name = "智眼 - 接口")
@RestController
@RequestMapping("/system/ivrs")
@Validated
public class IvrsController {

    @Resource
    private IvrsService ivrsService;

    @Value("${fileData.nas}")
    private String nas;

    @GetMapping("/ovr/image")
    @Operation(summary = "OCR图像识别")
//    @PreAuthorize("@ss.hasPermission('ivrs:ovr:image')")
    public CommonResult<String> ovrImage(@RequestParam("url") String url) {
        String path = "";
        if (url.split(nas).length > 1) {
            path = url.split(nas)[1];
        } else {
            path = url;
        }
        return success(ivrsService.ovrImagePath(path));
    }
}
